import 'package:cms/models/term.dart';
import 'package:common/dio/model.dart';

class CmsConfigurationModel extends BaseModel {
  String? homeLayoutStyle;
  List<WpTerm>? homeShowCategory;
  bool? showTopModule;

  CmsConfigurationModel({
    this.homeLayoutStyle,
    this.homeShowCategory,
    this.showTopModule,
  });

  CmsConfigurationModel.fromJson(Map<String, dynamic> json) {
    homeLayoutStyle = json['home_layout_style'];
    if (json['home_show_category'] != null) {
      homeShowCategory = <WpTerm>[];
      json['home_show_category'].forEach((v) {
        homeShowCategory!.add(WpTerm.fromJson(v));
      });
    }
    showTopModule = json['show_top_module'];
  }

  @override
  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['home_layout_style'] = homeLayoutStyle;
    if (homeShowCategory != null) {
      data['home_show_category'] = homeShowCategory!
          .map((v) => v.toJson())
          .toList();
    }
    data['show_top_module'] = showTopModule;

    return data;
  }
}
